#include "../../include/graphics/Primitive.hpp"
#include "../../include/Engine.hpp"

#include <cmath>

using namespace klas;
using namespace graphics;

Primitive::Primitive()
  : Renderable(this)
{
  setShape(primitiveTypes::RECTANGLE);
  setColor(colors::DarkGreen);
}

void Primitive::setColor(const Color& col)
{
  m_color = col;
}

Color Primitive::getColor() const
{
  return m_color;
}

void Primitive::setShape(primitiveTypes::ePrimitiveType type, double angle)
{
  m_primitiveType.angle = angle;
  m_primitiveType.primitiveType = type;
}

primitiveTypes::sPrimitiveType Primitive::getShape() const
{
  return m_primitiveType;
}

void Primitive::setPolygonMode(primitiveTypes::ePolygonMode mode)
{
  m_primitiveType.polygonMode = mode;
}

primitiveTypes::ePolygonMode Primitive::getPolygonMode() const
{
  return m_primitiveType.polygonMode;
}

void Primitive::renderElement(RenderingCore* core, const math::Vector2d& origin)
{
  Transformation transform = m_transform;
  transform.pos += origin;
  core->add(m_primitiveType, transform, m_color, m_transparency);
}